/******************************************************************************
 * Copyright (C) 2021 Batonova
 * All rights reserved.
 *****************************************************************************/

/**
 * @file IDeserializer.h
 * @brief An Interface for deserializer.
 *
 * A deserializer is a helper object of the communication layer
 * of Deviceware, it is used to deserializing data from Requests,
 * Responses and Notifications.
 *
 * @author batonova
 * @date 21 June 2021
 */

#ifndef _DRA_COM_IDESERIALIZER_H_
#define _DRA_COM_IDESERIALIZER_H_

#include <array>
#include <map>
#include <unordered_map>
#include <memory>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
// #include "dra/core/typedefine.h"
#include "serialize/typedefine.h"
// #include "ara/core/error_code.h"
// #include "ara/core/domains_registry.h"
#include "serialize/ProtocolDef.h"

namespace dra {
namespace com {

// using namespace deviceware::base;  // NOLINT

/** @addtogroup communication
 * @brief common interfaces of dra.com
 *
 * @{
 */
/**
 * @brief An Interface for deserializer.
 *
 * A deserializer is a helper object of the communication layer
 * of Deviceware, it is used to deserializing data from Requests,
 * Responses and Notifications.
 *
 */
class IDeserializer {
public:
    virtual ~IDeserializer() {
    }

    /**
     * @brief Get a BOOLEAN value from deserializer.
     *
     * @param[out] b the BOOLEAN value deserialized from deserializer,
     * it will be undefined value if return value is false.
     * @return true if deserialization is succeed else false.
     */
    virtual BOOLEAN getBoolean(BOOLEAN &b) = 0;

    /**
     * @brief Get a INT8 value from deserializer.
     *
     * @param[out] i the INT8 value deserialized from deserializer,
     * it will be undefined value if return value is false.
     * @return true if deserialization is succeed else false.
     */
    virtual BOOLEAN getInt8(INT8 &i) = 0;

    /**
     * @brief Get a INT16 value from deserializer.
     *
     * @param[out] i the INT16 value deserialized from deserializer,
     * it will be undefined value if return value is false.
     * @return true if deserialization is succeed else false.
     */
    virtual BOOLEAN getInt16(INT16 &i) = 0;

    /**
     * @brief Get a INT32 value from deserializer.
     *
     * @param[out] i the INT32 value deserialized from deserializer,
     * it will be undefined value if return value is false.
     * @return true if deserialization is succeed else false.
     */
    virtual BOOLEAN getInt32(INT32 &i) = 0;

    /**
     * @brief Get a INT64 value from deserializer.
     *
     * @param[out] i the INT64 value deserialized from deserializer,
     * it will be undefined value if return value is false.
     * @return true if deserialization is succeed else false.
     */
    virtual BOOLEAN getInt64(INT64 &i) = 0;

    /**
     * @brief Get a UINT8 value from deserializer.
     *
     * @param[out] i the  value deserialized from deserializer,
     * it will be undefined value if return value is false.
     * @return true if deserialization is succeed else false.
     */
    virtual BOOLEAN getUInt8(UINT8 &i) = 0;

    /**
     * @brief Get a UINT16 value from deserializer.
     *
     * @param[out] i the UINT16 value deserialized from deserializer,
     * it will be undefined value if return value is false.
     * @return true if deserialization is succeed else false.
     */
    virtual BOOLEAN getUInt16(UINT16 &i) = 0;

    /**
     * @brief Get a UINT32 value from deserializer.
     *
     * @param[out] i the UINT32 value deserialized from deserializer,
     * it will be undefined value if return value is false.
     * @return true if deserialization is succeed else false.
     */
    virtual BOOLEAN getUInt32(UINT32 &i) = 0;

    /**
     * @brief Get a UINT64 value from deserializer.
     *
     * @param[out] i the UINT64 value deserialized from deserializer,
     * it will be undefined value if return value is false.
     * @return true if deserialization is succeed else false.
     */
    virtual BOOLEAN getUInt64(UINT64 &i) = 0;

    /**
     * @brief Get a FLOAT32 value from deserializer.
     *
     * @param[out] f the FLOAT32 value deserialized from deserializer,
     * it will be undefined value if return value is false.
     * @return true if deserialization is succeed else false.
     */
    virtual BOOLEAN getFloat32(FLOAT32 &f) = 0;

    /**
     * @brief Get a FLOAT64 value from deserializer.
     *
     * @param[out] f the FLOAT64 value deserialized from deserializer,
     * it will be undefined value if return value is false.
     * @return true if deserialization is succeed else false.
     */
    virtual BOOLEAN getFloat64(FLOAT64 &f) = 0;

    /**
     * @brief Get a string from deserializer.
     *
     * @param[out] str the pointer of string buffer deserialized from deserializer,
     * it will be undefined value if return value is false.
     * @param[out] retStrLen the length of string buffer deserialized from deserializer,
     * it will be undefined value if return value is false.
     * @return true if deserialization is succeed else false.
     */
    virtual BOOLEAN getString(CHAR const*& str, INT32& retStrLen) = 0;

    /**
     * @brief Get a File Descriptor to deserializer.
     *
     * @param[out] fd the File Descriptor serialized to serializer
     * @return true if deserialization is succeed else false.
     */
    virtual BOOLEAN getFD(INT32& fd) = 0;

    /**
    *-----------------------------------------------------------------------------
     * @brief Get the Proto Type
     * 
     * @return SERIALIZE_TYPE 
     *-----------------------------------------------------------------------------
    */
    virtual SERIALIZE_TYPE GetSerializeType() = 0;
};

}  // namespace com
}  // namespace dra

#endif  // _DRA_COM_IDESERIALIZER_H_
